package com.zijie.hosptal.tools;

import com.zijie.hosptal.controller.DoctorSchedulesController;
import com.zijie.hosptal.controller.ReserveController;
import com.zijie.hosptal.pojo.po.DoctorSchedules;
import com.zijie.hosptal.pojo.po.Reserve;
import dev.langchain4j.agent.tool.Tool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.time.LocalDateTime;

@Component
@Slf4j
public class InterviewQuestionTool {

    private DoctorSchedulesController doctorSchedulesController;
    private ReserveController reserveController;

    @Autowired
    public void setDoctorSchedulesController(DoctorSchedulesController doctorSchedulesController) {
        this.doctorSchedulesController = doctorSchedulesController;
    }

    @Autowired
    public void setReserveController(ReserveController reserveController) {
        this.reserveController = reserveController;
    }

    @Tool(name = "interviewQuestionSearch",value = """
            当用户提问医院有什么义诊活动的时候，想要了解义诊活动的信息的时候
            ，或者当用户提问关于医院义诊活动信息的时候调用这个函数
            """)
    public String interviewQuestionSearch(String question) {
        DoctorSchedules doctorSchedules = new DoctorSchedules();
        doctorSchedules.setStatus("1");
//        doctorSchedules.setStartTime(LocalDateTime.now());
        return doctorSchedulesController.getAllDoctorSchedules(null, null, doctorSchedules).getData().toString();
    }
    @Tool(name = "reserveDoctorSchedules",value = """
            当用户说想要预约的时候，让用户提供医院下发的患者ID，以及活动编号，可以
            调用这个函数帮助患者去预约活动,并返回结果告诉用户成功还是失败,
            如果这个函数执行失败，获抛出异常，则返回异常信息，如果没有对应的信息,则提醒用户重新确认活动ID和患者ID是否正确；
            """)
    public String reserveDoctorSchedules(Integer patientId,Integer doctorSchedulesId) {
        Reserve reserve = new Reserve();
        reserve.setPatientId(patientId);
        reserve.setScheduleId(doctorSchedulesId);
        return reserveController.addReserve(reserve).getData().toString();
    }
}
